<template>
  <a-form :model="user" :label-col="labelCol" :wrapper-col="wrapperCol">
    <a-form-item label="账号">
      <a-input v-model:value="user.u_id" placeholder="please select your id" />
    </a-form-item>

    <a-form-item label="密码">
      <a-input-password
        v-model:value="user.u_pwd"
        placeholder="please select your password"
      />
    </a-form-item>

    <a-form-item :wrapper-col="{ span: 14, offset: 4 }">
      <a-button type="primary" @click="login">登录</a-button>
    </a-form-item>
  </a-form>
</template>
<script setup>
import { reactive } from "vue";
import { post ,setLocalToken} from "@/common";
import { useRouter } from "vue-router";

const router =useRouter();


const user = reactive({
  u_id: "",
  u_pwd: "",
});

const login = () => {
  console.log("submit!");

  post('/security/login', user).then((res) => {
    console.log(res);

    const token =res.data;

    setLocalToken(token);

    router.push({ path: "/home" });
  });
};

const labelCol = {
  span: 4,
};
const wrapperCol = {
  span: 14,
};
</script>